package com.zi.experttalk.experttalk.View;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import com.zi.experttalk.experttalk.Model.service.LocationManager;
import com.zi.experttalk.experttalk.R;


/**
 * Created by lenovo on 2014/12/10.
 */
public class NearActivity extends Activity {

    private Button near_location_Button;
    private Button near_map_Button;
    private Button near_list_Button;
    private ListView near_list_ListView;
    private TextView near_location_TextView;
    private Button near_range_Button;
    private Button near_class_Button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.near);

        near_location_Button = (Button) findViewById(R.id.near_location_Button);
        near_range_Button = (Button) findViewById(R.id.near_range_Button);
        near_class_Button = (Button) findViewById(R.id.near_class_Button);
        near_list_ListView = (ListView) findViewById(R.id.near_list_ListView);
        near_location_TextView = (TextView) findViewById(R.id.near_location_TextView);

        //初始化定位
        LocationManager locationManager = new LocationManager(NearActivity.this);
        locationManager.getCurrentLocation(NearActivity.this);

        /**
         *near_location_Button点击事件
         */
        near_location_Button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.d("onClick", "点击location");
            }
        });
        near_map_Button = (Button) findViewById(R.id.near_map_Button);
        /**
         *near_map_Button点击事件
         */
        near_map_Button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                near_list_Button.setVisibility(View.VISIBLE);
                near_map_Button.setVisibility(View.GONE);
                near_list_ListView.setVisibility(View.GONE);
                Log.d("onClick", "点击map");
            }
        });
        near_list_Button = (Button) findViewById(R.id.near_list_Button);
        /**
         *near_list_Button点击事件
         */
        near_list_Button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                near_list_Button.setVisibility(View.GONE);
                near_map_Button.setVisibility(View.VISIBLE);
                near_list_ListView.setVisibility(View.VISIBLE);
                Log.d("onClick", "点击list");
            }
        });
        /**
         * near_range_Button点击事件
         */
        near_range_Button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final String[] range = new String []{"1000米", "2000米", "3000米", "4000米", "5000米"};
                AlertDialog.Builder builder_range = new AlertDialog.Builder(NearActivity.this);
                builder_range.setItems(range,new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Log.d("onClick", which+"");
                        near_range_Button.setText(range[which]);
                        Log.d("range", range[which]+"");
                    }
                }).show();

                Log.d("onClick", "点击range");
            }
        });
        /**
         *near_class_Button点击事件
         */
        near_class_Button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Log.d("onClick", "点击class");
            }
        });
    }
}
